import { ApiProperty } from '@nestjs/swagger'
import { IsInt, IsOptional, IsString, Min, MinLength } from 'class-validator'

import { PagerDto } from '~/common/dto/pager.dto'

export class DictDataSaveDto {
  @ApiProperty({ description: '字典数据ID' })
  @IsInt()
  @Min(0)
  @IsOptional()
  id?: number

  @ApiProperty({ description: '字典排序' })
  @IsOptional()
  @IsInt()
  sort?: number

  @ApiProperty({ description: '字典标签' })
  @IsString()
  @MinLength(1)
  label: string

  @ApiProperty({ description: '字典键值' })
  @IsString()
  @MinLength(1)
  value: string

  @ApiProperty({ description: '字典类型' })
  @IsString()
  @MinLength(1)
  dictType: string

  @ApiProperty({ description: '状态（0正常 1停用）' })
  @IsOptional()
  @IsInt()
  status?: number

  @ApiProperty({ description: '颜色类型' })
  @IsOptional()
  @IsString()
  colorType?: string

  @ApiProperty({ description: 'css 样式' })
  @IsOptional()
  @IsString()
  cssClass?: string

  @ApiProperty({ description: '备注' })
  @IsOptional()
  @IsString()
  remark?: string
}

export class DictDataQueryDto extends PagerDto {
  @ApiProperty({ description: '字典类型' })
  @IsString()
  @IsOptional()
  dictType?: string

  @ApiProperty({ description: '字典标签' })
  @IsString()
  @IsOptional()
  label?: string

  @ApiProperty({ description: '字典键值' })
  @IsString()
  @IsOptional()
  value?: string
}
